/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-07-29
 * Time: 21:54
 */
package thread;
class Singleton {
    private static Singleton instance = new Singleton();

    public static Singleton getInstance() {
        return instance;
    }

    // 做出一个限制, 禁止别人去 new 这个实例!!
    private Singleton() {}
}
    public class Test{
        public static void main(String[] args) {
            Singleton s1 = Singleton.getInstance();
            Singleton s2 = Singleton.getInstance();

            // Singleton s3 = new Singleton();

            System.out.println(s1 == s2);
        }
}
